﻿#region

using System.Data.Entity.ModelConfiguration;
using HouseHoldBudget.Core.Entities.Expenses;

#endregion

namespace HouseHoldBudget.Data.Mapping.Expenses
{
    public class ExpenseMap : EntityTypeConfiguration<Expense>
    {
        #region Constructors

        public ExpenseMap()
        {
            ToTable("Expenses");
            HasKey(c => c.Id);

            Property(u => u.ExpenseAmount);
            Property(u => u.ExpenseLabel);
            Property(u => u.ExpenseOn);

            HasOptional(c => c.ExpensesTypes)
                .WithMany()
                .HasForeignKey(p => p.ExpensesTypeId)
                .WillCascadeOnDelete(false);

            HasOptional(fp => fp.BudgetUser)
                .WithMany(p => p.Expenses)
                .HasForeignKey(fp => fp.BudgetUserId)
                .WillCascadeOnDelete(false);
        }

        #endregion
    }
}